package com.cy.pj.common.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
/**
 * 1)序列化：将对象转换为字节
 * 2）反序列haul：将字节转换为对象
 * 反序列化应用场景
 * 1）将对象转换为字节以后缓存到内存
 * 2）将内存中的对象存储到文件
 * 3）将对象转换为字节在网络中进行加密传输
 * 序列化规范
 */
public class PageObject<T> implements Serializable{
    private static final long serialVersionUID = 3910560732097792785L;//当泛型定义在累活接口名的右侧是这种泛型

    /**总记录数*/
private Long rowCount;
/**当前页记录*/
private List<T> records;
/**当前页数*/
private Long pageCurrent;
/**，每页显示的记录条数*/
private Integer pageSize;
/**总页数*/
private Long pageCount;

    public PageObject(Long rowCount, List<T> records,Integer pageSize, Long pageCurrent) {
        super();
        this.rowCount = rowCount;
        this.records = records;
        this.pageSize = pageSize;
        this.pageCurrent = pageCurrent;
        //计算pageCount的值,方法1
//		this.pageCount=rowCount/pageSize;
//		if(rowCount%pageSize!=0)this.pageCount++;
        //计算pageCount的值,方法2
        this.pageCount=(this.rowCount-1)/pageSize+1;
    }

}
